Python: Preserve null arguments during tool invocation#5944
Open
shusingh wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates Python core tool invocation to preserve explicitly supplied null values through Pydantic argument validation, addressing required nullable tool parameters during direct and automatic invocation.
Changes:
- Adds a helper for dumping Pydantic argument models while restoring explicit top-level
Nonevalues. - Applies the helper in
FunctionTool.invoke()and automatic function calling. - Adds regression tests for direct and automatic nullable required arguments.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
python/packages/core/agent_framework/_tools.py |
Updates argument dumping in tool invocation paths to preserve explicit None values. |
python/packages/core/tests/core/test_tools.py |
Adds direct FunctionTool.invoke() regression coverage. |
python/packages/core/tests/core/test_function_invocation_logic.py |
Adds automatic function calling regression coverage. |
35a9f72 to
c0fedbb
Compare
Author
|
Updated the PR to handle nested explicit null values as well. The argument dump helper now recursively restores explicitly provided nulls in nested Pydantic models, mappings, and lists/tuples, and I added regression coverage for both direct tool invocation and automatic function calling with nested nullable arguments. |
moonbox3
approved these changes
May 22, 2026
Contributor
Python Test Coverage Report •
Python Unit Test Overview
|
||||||||||||||||||||||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
nullvalues when dumping validated tool argumentsFunctionTool.invoke()and automatic function callingFixes #5934
Tests
python -m pytest tests/core/test_tools.py::test_tool_invoke_preserves_explicit_null_for_required_nullable_argument tests/core/test_function_invocation_logic.py::test_auto_function_calling_preserves_explicit_null_arguments -qpython -m pytest tests/core/test_tools.py tests/core/test_function_invocation_logic.py -qpython -m ruff check agent_framework/_tools.py tests/core/test_tools.py tests/core/test_function_invocation_logic.py